package jjn.round1;

import java.util.Scanner;

/**
 * @author Jjn
 * @since 2023/8/17 18:32
 */
public class LeetCode56 {
    public String addBinary(String a, String b) {
        char[] first = a.toCharArray();
        char[] second = b.toCharArray();
        int carry = 0;
        int min = Math.min(first.length, second.length);
        StringBuilder stringBuilder = new StringBuilder();
        for (int i = 0; i < min; i++) {
            int firstDigit = first[first.length - 1 - i] - '0';
            int secondDigit = second[second.length - 1 - i] - '0';
            int sum = firstDigit + secondDigit + carry;
            carry = (sum >= 2) ? 1 : 0;
            stringBuilder.append(sum % 2);
        }
        while (first.length > min) {
            int sum = first[first.length - min - 1] - '0' + carry;
            carry = (sum >= 2) ? 1 : 0;
            stringBuilder.append(sum % 2);
            min++;
        }
        while (second.length > min) {
            int sum = second[second.length - min - 1] - '0' + carry;
            carry = (sum >= 2) ? 1 : 0;
            stringBuilder.append(sum % 2);
            min++;
        }
        if (carry > 0) {
            stringBuilder.append(carry);
        }
        return stringBuilder.reverse().toString();
    }
    
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String a = scanner.nextLine();
        String b = scanner.nextLine();
        String result = new LeetCode56().addBinary(a, b);
        System.out.println(result);
    }
}
